package com.cat.twoPointerTechnique;

import java.util.Arrays;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/maximum-distance-between-a-pair-of-values/
 * @create 2025/8/4 19:19
 * @since JDK17
 */

public class Solution13 {
    public int maxDistance(int[] nums1, int[] nums2) {
        int ans = 0, n = nums1.length, m = nums2.length;
        for (int i = 0, j = 0; i < n; i++) {
            while (j < m && nums1[i] < nums2[j]) {
                j++;
            }
            ans = Math.max(ans, n - (j - i) - 1);
        }
        return ans;
    }
}
